package com.designoutput.ui.options
{
	import com.designoutput.elements.EllipseElement;
	import com.designoutput.elements.RoundRectElement;
	import com.designoutput.event.NumberEvent;
	import com.designoutput.ui.controls.Literal;
	import com.designoutput.ui.controls.NumberInput;
	import com.designoutput.utils.Unit;
	import com.designoutput.utils.UnitUtils;
	import com.designoutput.manager.ResourceManager;

	public class RoundRectangleOption extends BaseRectOption
	{
		private var _radiusInput:NumberInput; 
		
		public function RoundRectangleOption(parent:DesignoutputCard)
		{
			super(parent);
			
			/***************************/
			
			var li:Literal = new Literal(ResourceManager.getValue("rm_radius"));
			li.x = 0;
			li.y = 222;
			addChild(li);
			
			_radiusInput = new NumberInput(40, 0, 0, Number.MAX_VALUE, true);
			_radiusInput.addEventListener(NumberEvent.VALUE_CHANGE, radiusChange);
			_radiusInput.x = 50;
			_radiusInput.y = 222;
			addChild(_radiusInput);
			
			addChild(depthManager);
			addChild(fillGroup);
			addChild(lineGroup);
			
			resize();
		}
		
		private function resize():void{
			depthManager.y = 247;
		}
		
		public function updateOptions(elementType:String,element:RoundRectElement,bothShirtAndSleeves:Boolean=false,forSleeveElements:Boolean=false):void{
			super.update(element,bothShirtAndSleeves,forSleeveElements);
			
			this._radiusInput.text = UnitUtils.convert(element.getR(), Unit.PIXELS,  card.unit).toString();
		}
		
		private function radiusChange(evt:NumberEvent):void{
			if(!isNaN(evt.value)){
				this.designOutputCard.command.changeElementRadius(UnitUtils.convert(evt.value, card.unit, Unit.PIXELS));
			}
		}
	}
}